package com.msb.base;

public class Demo1 {

    public static void main(String[] args) {
        Factory factory = new User("zhangsan");
        System.out.println(factory.get());

        factory = new Factory() {
            @Override
            public Object get() {
                return new User("lisi");
            }
        };
        System.out.println(factory.get());

        //函数式接口：有且只有一个接口
        factory = () -> {
            return new User("wangwu");
        };
        System.out.println(factory.get());
    }

    public void test1() {
        //lambda表达式，参数是lambda表达式
        new Thread(() -> {
            System.out.println("开始。。。。。");
        });

        //不重写run方法，没有用
        Thread t = new Thread();

        //内部类，重写run方法
        new Thread(){
            @Override
            public void run() {
                System.out.println("开始。。。。。");
            }
        }.start();
    }
}
